<script>
	export default {
		onLaunch: function() {
			console.log('App Launch');

			const getLocation = (ref) => {
				wx.getLocation({
					success: (res) => {
						console.log("司机的当前位置", res);
						const {
							latitude,
							longitude
						} = res;
						//接单偏好设置 本地缓存

						const settings = {
							orderDistance: 0, //订单距离
							rangeDistance: 5,
							orientation: ''
						};

						const {
							orderDistance,
							rangeDistance,
							orientation
						} = settings;
						const data = {
							latitude,
							longitude,
							orderDistance,
							rangeDistance,
							orientateLongitude: orientation ? orientation.longitude : null,
							orientateLatitude: orientation ? orientation.latitude : null
						};

						//上传司机位置信息到redis 
						this.request(this.urls.updateOrderInfo, 'POST', data, (resp) => {
							console.log("上传司机的当前位置响应", resp);
						});
					},

				})

			}

			const ref = this;
			setInterval(function() {
				getLocation(ref);
			}, 30000)

		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang="scss">
	@import "uview-ui/index.scss";
</style>